/*
 * CommandsQueue.h
 *
 *  Created on: Dec 13, 2014
 *      Authors: Avihay Avitan & Stefan Farcas
 */
#include "SatelliteUplinkCommand.h"
#include <queue>

#ifndef COMMANDSQUEUE_H_
#define COMMANDSQUEUE_H_
using namespace std;

namespace SatelliteNameSpace {
/**
 * CommandsComparator is a class that implements the operator function that is responsible to decide which command should be before another
 * if there will be any other priority considerations that need to be take, they should be implemented here!
 */
class CommandsComparator
{
public:
	/**
	 * return whether s2 should be placed before s1
	 */
	bool operator()(SatelliteUplinkCommand * s1 , SatelliteUplinkCommand * s2)
	{
		if (s2->getCommandNum() < s1->getCommandNum() )
			return true;

		return false;
	}
};

/**
 * CommandsQueue implement the model of the commands queue
 */
class CommandsQueue {
public:
	CommandsQueue();
	virtual ~CommandsQueue();
	bool addUplinkCommand(SatelliteUplinkCommand * command);
	SatelliteUplinkCommand * popNextCommand();
	SatelliteUplinkCommand * getTopCommand();
	int getCountOfCommands();
	bool hasNextCommand();

private:
	priority_queue< SatelliteUplinkCommand * , vector<SatelliteUplinkCommand *>, CommandsComparator > commandsVec;
};

} /* namespace SatelliteNameSpace */

#endif /* COMMANDSQUEUE_H_ */
